﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Admin.Core.Service.sys.User.Dto/SysUserDto 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       SysUserDto
* 创建时间：  2025/6/4 11:07:56
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion
using SSPivot.Admin.Core.Service.sys.Org.Dto;
using SSPivot.Admin.Core.Service.sys.Role.Dto;
using SSPivot.AspNetCore.Abstractions.User;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Admin.Core.Service.sys.User.Dto
{

    public class SysUserDto
    {
        public long? Id { get; set; }
        public virtual long? TenantId { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        [StringLength(60)]
        public string? Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [StringLength(200)]
        public string? Password { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [StringLength(60)]
        public string? Name { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        [StringLength(20)]
        public string? Mobile { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [StringLength(100)]
        public string? Email { get; set; }

        /// <summary>
        /// 主属部门Id
        /// </summary>
        public long OrgId { get; set; }


        /// <summary>
        /// 直属主管Id
        /// </summary>
        public long? ManagerUserId { get; set; }


        /// <summary>
        /// 昵称
        /// </summary>
        [StringLength(60)]
        public string? NickName { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        [StringLength(500)]
        public string? Avatar { get; set; }

        /// <summary>
        /// 用户状态
        /// </summary>

        public UserStatus? Status { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>

        public UserType Type { get; set; } = UserType.DefaultUser;

        /// <summary>
        /// 最后登录时间
        /// </summary>
        [StringLength(100)]
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 最后登录IP
        /// </summary>
        [StringLength(100)]
        public string? LastLoginIP { get; set; }

        /// <summary>
        /// 最后登录国家
        /// </summary>
        [StringLength(100)]
        public string? LastLoginCountry { get; set; }

        /// <summary>
        /// 最后登录省份
        /// </summary>
        [StringLength(100)]
        public string? LastLoginProvince { get; set; }

        /// <summary>
        /// 最后登录城市
        /// </summary>
        [StringLength(100)]
        public string? LastLoginCity { get; set; }

        /// <summary>
        /// 启用
        /// </summary>
        public bool Enabled { get; set; } = true;

         
        /// <summary>
        /// 部门
        /// </summary>

        public SysOrgDto? Org { get; set; }
        /// <summary>
        /// 直属主管
        /// </summary>

        public SysUserDto? ManagerUser { get; set; }
         
        /// <summary>
        /// 角色列表
        /// </summary>                                     
        public ICollection<SysRoleDto> Roles { get; set; }

        /// <summary>
        /// 部门列表
        /// </summary>                                     
        public List<SysOrgDto> Orgs { get; set; }
    }

    public class QuerySysUserRequset
    {
        public string? Key { get; set; }
        public long? OrgId { get; set; }
        public DateTime? SDate { get; set; }
        public DateTime? EDate { get; set; }
    }

    public class UserGetRoleDto
    {
        public long Id { get; set; }
        public string Name { get; set; }
    }


    public class UserGetDto : SysUserDto
    {
        /// <summary>
        /// 角色列表
        /// </summary>
        public List<UserGetRoleDto> Roles { get; set; }

        /// <summary>
        /// 角色Ids
        /// </summary>
        public long[] RoleIds => Roles?.Select(a => a.Id)?.ToArray();
    }


    /// <summary>
    /// 用户分页查询响应
    /// </summary>
    public class UserGetPageDto
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        public UserType Type { get; set; }


        public List<SysRoleDto> Roles { get; set; }

        /// <summary>
        /// 角色
        /// </summary>
        public string[] RoleNames { get; set; }

        /// <summary>
        /// 是否主管
        /// </summary>
        public bool IsManager { get; set; }

        /// <summary>
        /// 启用
        /// </summary>
        public bool Enabled { get; set; }

        /// <summary>
        /// 在线
        /// </summary>
        public bool Online { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedTime { get; set; }
    }

    /// <summary>
    /// 用户基本信息
    /// </summary>
    public class UserGetBasicDto
    {
        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        public string NickName { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 最后登录IP
        /// </summary>
        public string LastLoginIP { get; set; }

        /// <summary>
        /// 最后登录国家
        /// </summary>
        public string LastLoginCountry { get; set; }

        /// <summary>
        /// 最后登录省份
        /// </summary>
        public string LastLoginProvince { get; set; }

        /// <summary>
        /// 最后登录城市
        /// </summary>
        public string LastLoginCity { get; set; }
    }


    /// <summary>
    /// 添加
    /// </summary>
    public class SysUserAddDto : UserFormDto
    {
        /// <summary>
        /// 所属部门Ids
        /// </summary>
        public virtual long[] OrgIds { get; set; }

        /// <summary>
        /// 主属部门Id
        /// </summary>
        public long OrgId { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        public virtual string Password { get; set; }

        /// <summary>
        /// 启用
        /// </summary>
        public bool Enabled { get; set; } = true;
    }


    /// <summary>
    /// 修改
    /// </summary>
    public partial class SysUserUpdateDto : UserFormDto
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Required]
        public override long Id { get; set; }
    }

    public class UserFormDto
    {
        /// <summary>
        /// 用户Id
        /// </summary>
        public virtual long Id { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        [Required(ErrorMessage = "请输入账号")]
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [Required(ErrorMessage = "请输入姓名")]
        public string Name { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 角色Ids
        /// </summary>
        public virtual long[] RoleIds { get; set; }

        /// <summary>
        /// 直属主管Id
        /// </summary>
        public long? ManagerUserId { get; set; }

        /// <summary>
        /// 直属主管姓名
        /// </summary>
        public string ManagerUserName { get; set; }

        
    }

    /// <summary>
    /// 添加会员
    /// </summary>
    public class SysUserAddMemberDto : SysUserMemberFormDto
    {
        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "请输入密码")]
        public string Password { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public UserStatus Status { get; set; }
    }


    /// <summary>
    /// 会员表单
    /// </summary>
    public class SysUserMemberFormDto
    {
        /// <summary>
        /// 会员Id
        /// </summary>
        public virtual long Id { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        [Required(ErrorMessage = "请输入账号")]
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }
    }

}
